package com.wtcrazy.controller;

import com.wtcrazy.entity.Address;
import com.wtcrazy.service.Impl.AddressServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/address")
public class AddressController {
    @Autowired
    AddressServiceImpl addressService;
    @ApiOperation("【拦截】用户添加自己的新地址")
    @PostMapping("/userAdd")//
    public Address userAdd(@RequestBody Address address) {
        return addressService.userAdd(address);
    }
    @ApiOperation("【拦截】获取该用户全部的地址")
    @GetMapping("/getUserAll")//
    public List<Address> getUserAll(@RequestParam(required = false) String uid) {
        return addressService.getUserAll(uid);
    }
    @ApiOperation("【拦截】修改用户默认地址")
    @PutMapping("/modifyUserDefault")//
    public Object modifyUserDefault(@RequestBody Object obj) {
        addressService.modifyUserDefault(obj);
        return obj;
    }
    @ApiOperation("【拦截】获取用户的默认地址")
    @GetMapping("/getUserDefault")//
    public Address getUserDefault(@RequestParam String uid) {
        return addressService.getUserDefault(uid);
    }
}
